#ifndef QANIMATIONSTACKEDWIDGET_H
#define QANIMATIONSTACKEDWIDGET_H

#include <QWidget>
#include <QList>
#include <QPropertyAnimation>

class QAnimationStackedWidget : public QWidget
{
    Q_OBJECT

public:
    QAnimationStackedWidget(QWidget *parent = nullptr);
    ~QAnimationStackedWidget();

    void setDuration(int duration);
    int addWidget(QWidget * widget);
    int insertWidget(int index, QWidget * widget);
    void removeWidget(QWidget * widget);
    void setCurrentWidget(QWidget * widget);
    void setCurrentIndex(int index);
    void resizeEvent(QResizeEvent *event);
    void moveAnimationStart();
    void setWidgetsVisible();

    int count() const;
    int currentIndex() const;
    int indexOf(QWidget * widget) const;
    QWidget* currentWidget() const;
    QWidget* widget(int index) const;

signals:
    void currentChanged(int);
    void widgetRemoved(int);

protected slots:
    void onValueChanged(const QVariant &value);

private:
    QList<QWidget* > m_widgetLst;

    int m_offset;
    int m_curIndex;
    int m_lastIndex;
    int m_duration;
    QPropertyAnimation* m_moveAnimation;


};
#endif // QANIMATIONSTACKEDWIDGET_H

